require 'singly'
require 'vcr'

RSpec.configure do |config|
  config.color_enabled = true

  defaults = {                  # Restore defaults before each test to
    version: Singly.version,    # avoid transitive failures
    verbose: Singly.verbose,
    timeout: Singly.timeout,
    client_id: Singly.client_id,
    client_secret: Singly.client_secret
  }
  config.before(:each) do
    Singly.version = defaults[:version]
    Singly.verbose = defaults[:verbose]
    Singly.timeout = defaults[:timeout]
    Singly.client_id = defaults[:client_id]
    Singly.client_secret = defaults[:client_secret]
  end
end

VCR.configure do |config|
  config.cassette_library_dir = 'spec/vcr_cassettes'
  config.hook_into :typhoeus
  # config.allow_http_connections_when_no_cassette = true
end

def vcr(cassette)
  VCR.use_cassette(cassette) do
    yield
  end
end